package com.snowy.hidden.user.service.impl;

import cn.hutool.core.util.EnumUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snowy.hidden.constant.CommonDeleteFlagEnum;
import com.snowy.hidden.user.domain.model.SysOrg;
import com.snowy.hidden.user.domain.req.BizOrgCategoryReq;
import com.snowy.hidden.user.mapper.SysOrgMapper;
import com.snowy.hidden.user.service.SysOrgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 组织(SysOrg)表服务实现类
 *
 * @author makejava
 * @since 2023-11-30 00:38:28
 */
@Service("sysOrgService")
public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> implements SysOrgService {

	@Resource
    private SysOrgMapper sysOrgMapper;


    @Override
    public List<SysOrg> listByCategoryAndDepth(BizOrgCategoryReq bizOrgCategoryReq) {
        LambdaQueryWrapper<SysOrg> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysOrg::getCategory,bizOrgCategoryReq.getCategory());
        queryWrapper.eq(SysOrg::getDepth,bizOrgCategoryReq.getDepth());
        queryWrapper.eq(SysOrg::getDeleteFlag, EnumUtil.toString(CommonDeleteFlagEnum.NOT_DELETE));
        queryWrapper.orderByAsc(SysOrg::getSortCode);
        List<SysOrg> bizOrgList = this.list(queryWrapper);
        return bizOrgList;
    }
}
